#include<stdio.h>
#include<unistd.h>
#include<sys/types.h>
#include<sys/wait.h>

int main()
{
	pid_t id=fork();

	if(id==0)
	{
	//子进程
	
		while(1)
		{
			printf("i am child process,pid:%d",getpid());
			sleep(5);
			exit(1);
		}
	}

	//父进程
	
	int status=0;
	pid_t rid=waitpid(id,&status,0);
	if(rid>0)
	{
		printf("等待子进程成功\n");
		sleep(1);
	}
	else
	{
		perror("waitpid");
	}
	return 0;
}
